package demo3;

import java.util.Arrays;
import java.util.Comparator;

public class test {



    public static void Bubble(Student[] stu, Comparator<Student> com){

        for(int i=0;i<stu.length;i++){

            for(int j=0;j<stu.length-1-i;j++){
                if(com.compare(stu[j],stu[j+1])>0){

                    Student temp=stu[j];
                    stu[j]=stu[j+1];
                    stu[j+1]=temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        Student[] stus=new Student[3];
        stus[0]=new Student("zhangsan",12);
        stus[1]=new Student("lisi",15);
       stus[2]=new Student("wangwu",11);

        namecomparator namecom=new namecomparator();
       Bubble(stus,namecom);

        System.out.println(Arrays.toString(stus));
    }
}
